package com.ost.kautilya.utils.metrics;

import com.ost.kautilya.utils.Metric.DataType;
import com.ost.kautilya.utils.StatisticalMetric;

public abstract class AbstractMetric<Type> extends StatisticalMetric<Type> {
	private static final long serialVersionUID = -963646970783984170L;
	public final DataType dt;

	protected AbstractMetric(DataType dt) {
		this.dt = dt;
	}

	protected abstract double asDouble();

	@Override
	public Number value() {
		Number val = asDouble();
		switch (dt) {
			case DOUBLE:
				return val.doubleValue();
			case LONG:
				return val.longValue();
			default:
				return val;
		}
	}
}
